package org.example.usercontroller;

import lombok.extern.slf4j.Slf4j;
import org.example.pojo.entity.Customer;
import org.example.pojo.Result;
import org.example.pojo.userdto.CustomerRegisterDTO;
import org.example.userservice.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserRegisterController {
    @Autowired
    private CustomerService customerService;

    @PostMapping("/register")
    public Result register(@RequestBody CustomerRegisterDTO customerRegisterDTO) {
        Customer customer = new Customer();
        customer.setUser(customerRegisterDTO.getUser());
        customer.setPassword(customerRegisterDTO.getPassword());
        customer.setEmail(customerRegisterDTO.getEmail());
        customerService.insert(customer);
        return Result.success();
    }
}